package com.google.zxing.client.android;

import com.google.zxing.client.android.camera.CameraManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import up_down_share.updaonwshare.v01.R;





public class CustomView extends View
{

	private final Paint paint;
	private final int color;
	private CameraManager cameraManager;
	private Rect caluteRect = null;

	// 当从xml获取资源的时候，系统将调用这个构造方法
	public CustomView(Context context, AttributeSet attrs)
	{
		super(context, attrs);

		// 在里面初始化Paint
		paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		Resources resources = getResources();
		color = resources.getColor(R.color.result_viewTest);

	}


	
	public void setRect(Rect caluteRect){
		
		this.caluteRect = caluteRect;
		
	}

	// Rect(int left 100, int top 60, int right 700, int bottom 420)
	@Override
	public void onDraw(Canvas canvas)
	{
		
;
		if (caluteRect == null)
		{
			return;
		}

		int width = canvas.getWidth();
		int height = canvas.getHeight();

		// Rect frame = new Rect(60, 100, 400, 420);

		paint.setColor(color);
		canvas.drawRect(0, 0, width, caluteRect.top, paint);
		canvas.drawRect(0, caluteRect.top,caluteRect.left, caluteRect.bottom + 1, paint);
		canvas.drawRect(caluteRect.right + 1, caluteRect.top, width, caluteRect.bottom + 1, paint);
		canvas.drawRect(0, caluteRect.bottom + 1, width, height, paint);
	}

}
